package com.fz.us.admin.company.service;

import com.fz.us.admin.base.bean.BaseEnumManager;
import com.fz.us.admin.base.bean.Result;
import com.fz.us.admin.base.bean.search.order.Order;
import com.fz.us.admin.base.bean.search.page.Page;
import com.fz.us.admin.base.bean.search.page.PagePaging;
import com.fz.us.admin.base.bean.search.result.SearchResult;
import com.fz.us.admin.base.bean.search.result.SearchResultList;
import com.fz.us.admin.base.bean.search.result.SearchResultPaging;
import com.fz.us.admin.base.bean.search.rule.Rule;
import com.fz.us.admin.base.service.BaseService;
import com.fz.us.admin.company.entity.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Service接口 - 职权
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-11 。
 * ============================================================================
 */
public interface PowerService extends BaseService<Power,String> {

    /**
     * 根据departId查找power
     * @param departId
     * @return
     */
    public List<Power> getByDepartId(String departId);

    /**
     * 根据department和post查找power
     * @param department
     * @param post
     * @return
     */
    public Power getPowerByDepartAndPost(Department department, Post post);

    /**
     * 获取当前职责的上一级职权的职责
     * @param duty
     * @return
     */
    public Set<Duty> findParentByPower(Duty duty);

    /**
     * 获取公司下的所有职权列表
     *
     * @param company 企业
     * @return
     */
    public List<Power> getAllPowers(Company company);

    /**
     * 获取公司下的顶级职权列表
     *
     * @param company 企业
     * @return
     */
    public List<Power> getRootPowers(Company company);

    /**
     * 获取职权下的职权列表
     *
     * @param company 企业
     * @param power 职权
     * @return
     */
    public List<Power> getPowers(Company company, Power power);

    /**
     * 获取职权同级及上级部门职权列表
     *
     * @param company 企业
     * @param department 部门
     * @return
     */
    public List<Power> getLevelPowers(Company company, Department department);

    /**
     * 是否有下级职权
     *
     * @param power
     * @return
     */
    public boolean isParentPower(Power power);

    /**
     * 是否存在岗位
     *
     * @param post
     * @return
     */
    public boolean hasPost(Post post);

    /**
     * 是否存在部门
     *
     * @param department
     * @return
     */
    public boolean hasDepartment(Department department);



    /**
     * 企业下职权 Map Tree
     *
     * @param company
     * @return
     */
    public List<Map<String, Object>> getTreeMapList(Company company);

    /**
     * 企业下同级及上级部门职权 Map Tree
     *
     * @param company
     * @param department
     * @param exceptPower
     * @return
     */
    public List<Map<String, Object>> getLevelTreeMapList(Company company, Department department, Power exceptPower);



    /**
     * 保存
     *
     * @param user
     * @param power
     * @return
     */
    public Result createEntity(User user, Power power);

    /**
     * 修改
     *
     * @param user
     * @param power
     * @return
     */
    public Result updateEntity(User user, String keyId, Power power);

    /**
     * 操作
     *
     * @param user
     * @param method
     * @param keyId
     * @return
     */
    public Result methodEntity(User user, String method, String keyId);

    /**
     * 分页 部门职权
     *
     * @param page
     * @param order
     * @param department
     * @return
     */
    public SearchResultPaging pagingPower(PagePaging page, List<Rule> rules, Order order, Company company, Department department, BaseEnumManager.StateEnum... states);

    /**
     * 分页 部门以及下级部门所有职权
     *
     * @param page
     * @param order
     * @param department
     * @return
     */
    public SearchResultPaging pagingAllPower(PagePaging page, List<Rule> rules, Order order, Company company, Department department, BaseEnumManager.StateEnum... states);

    /**
     * 列表 部门职权
     *
     * @param order
     * @param department
     * @param parent
     * @return
     */
    public SearchResultList listPower(List<Rule> rules, Order order, Company company, Department department, Power parent, BaseEnumManager.StateEnum... states);

    /**
     * 列表 Map
     *
     * @param power
     * @return
     */
    public Map<String, Object> getListMap(Power power);

    /**
     * 详情 Map
     *
     * @param power
     * @return
     */
    public Map<String, Object> getDetailMap(Power power);

    /**
     * tree Map
     *
     * @param power
     * @return
     */
    public Map<String, Object> getTreeMap(Power power);

    /**
     * 通过 标识 value 获取职权(要舍弃)
     *
     * @param company
     * @return
     */
    public Power getPowerByValue(Company company, String value);

}
